<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="x-ua-compatible" content="IE=8"/>
        <link rel="stylesheet" type="text/css" href="styles10.css">
        <style type="text/css">
			html,body{
				padding:0;margin:0;
			}
            .container { font:caption; padding: 10px 25px; word-wrap: break-word; white-space: pre-wrap; } 
			#div_text{ padding-top:10px; padding-bottom:20px; 
				background: #ffffff; /* Old browsers */
				background: -moz-linear-gradient(top,  #ffffff 0%, #f0f0f0 100%); /* FF3.6-15 */
				background: -webkit-linear-gradient(top,  #ffffff 0%,#f0f0f0 100%); /* Chrome10-25,Safari5.1-6 */
				background: linear-gradient(to bottom,  #ffffff 0%,#f0f0f0 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
				filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#f0f0f0',GradientType=0 ); /* IE6-9 */
			}
			#radio_container{
				background:#e0e0e0;
				padding-top:15px; padding-bottom:15px;
				border:1px solid #d0d0d0;
				border-width:1px 0;
			}
            input[type="radio"] { float:left; display: inline; position: relative; width: 15px; border: 0; padding: 2px 1px; margin:5px 0; } 
            input[type="radio"]:hover { border:1px solid #000000; padding: 1px 0; } 
            .radio_label { float:left; padding-top: 1px;  margin:5px 0;  margin-left:5px;} 			
            .button_ok { position: absolute; right: 100px; bottom: 8px; } 
            .button_cancel { width: 70px; position: absolute; right: 15px; bottom: 8px; } 
			.titleBig {
				font-size:130%;
				font-style: italic;
				text-align:center;
				padding-bottom:5px;
			}
			.separator{width:50px; background:#000; height: 1px; margin: 15px auto 5px; }
        </style>
        <title></title>
    </head>
    <body>
        <div id="div_text" class="container"></div>
        <div id="radio_container" class="container"></div>				
        <div id="bottom_msg" class="container"></div>		
		<button id="btn_cancel" class="button_cancel">Cancel</button>		
        <button class="button_ok" id="btn_ok">Ok</button>		
        <script>   
            // helpers
            function close_window() {
                window.open('', '_self', '');
                window.close();
            }

            // parse data
            var parsed_args;
            var callback_fn;
            try {
                parsed_args = window.external.dialogArguments.toArray();
            }
            catch(e) {
            }
            if (parsed_args) {
                document.title = parsed_args[0];
				
				window.div_text.insertAdjacentHTML('beforeend',parsed_args[1]);
				
                var labelInnerHtml = window.btn_cancel.innerHTML;
                window.btn_cancel.innerHTML = labelInnerHtml.replace(/Cancel/g, parsed_args[2]);
                callback_fn = parsed_args[3];
				
				var radio_string = parsed_args[4];
				var radio_btns = radio_string.split("##");
				var radio_btns_counter = 0;
				for (var i = 0; i < radio_btns.length; i++) {
				  window.radio_container.insertAdjacentHTML('beforeend', '<div><input type="radio" id="radio_btns_'+radio_btns_counter+'" name="radio_btns" value="'+radio_btns_counter+'" '+(parsed_args[5]==radio_btns_counter?'checked="checked"':'')+'><label for="radio_btns_'+radio_btns_counter+'" class="radio_label">'+radio_btns[i]+'</label></div>');
				  radio_btns_counter++;
				}		
				window.bottom_msg.insertAdjacentHTML('beforeend',parsed_args[6]);
            }
			
			function resize(){			
				var window_w = 458;
				window_h = 43 + window.div_text.offsetHeight + window.radio_container.offsetHeight + window.btn_ok.offsetHeight + window.bottom_msg.offsetHeight;
				if (window_w < window_h + 50) window_w += 50;
				window.resizeTo(window_w, window_h);
            }
			resize();
			
			document.onkeydown = function () {
				if (window.event.keyCode == 13 && window.document.activeElement.onclick) {
					window.document.activeElement.onclick();
				}
			};
            window.btn_ok.onclick = function () {
				var radio_check = document.getElementsByName('radio_btns');
				var radio_value;
				for(var i = 0; i < radio_check.length; i++){
					if(radio_check[i].checked){
						radio_value = radio_check[i].value;
					}
				}
                callback_fn && callback_fn("ok", radio_value);
                close_window();
            };
            window.btn_cancel.onclick = function () {
				callback_fn && callback_fn("cancel", false);
                close_window();
            };
            window.document.body.focus();
            window.btn_ok.focus();
        </script>
    </body>
</html>